package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.BaseContractorBankInfo;
import com.softer.wxzj.entity.SysBankOperator;
import com.softer.wxzj.service.SysBankOperatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: wxzj
 * @author: wxr
 * @create: 2019-07-02 12:06
 **/
@RequestMapping("/sysBankOperator")
@RestController
public class SysBankOperatorController {
    @Autowired
    private SysBankOperatorService sysBankOperatorService;

    /**
     * 添加银行用户
     *
     * @param sysBankOperator 实体
     */
    @RequestMapping("/add")
    @LogRecord(description = "注册银行用户", operationUnit = LogOperationUnit.SYS_BANK_OPREATOR, operationType = LogOperationType.INSERT)
    public CommonResult add(SysBankOperator sysBankOperator) {
        return sysBankOperatorService.insert(sysBankOperator);
    }

    /**
     * 删除银行用户
     *
     * @param id 用户ID
     * @return 操作结果
     */
    @RequestMapping("/delete")
    @LogRecord(description = "删除银行用户", operationUnit = LogOperationUnit.SYS_BANK_OPREATOR, operationType = LogOperationType.DELETE)
    public CommonResult delete(String id) {
        return sysBankOperatorService.delete(id);
    }

    /**
     * 开启/关闭银行用户
     *
     * @param id    用户ID
     * @param state 开启1 / 关闭0
     * @return 操作结果
     */
    @RequestMapping("/enable")
    @LogRecord(description = "开启/关闭银行用户", operationUnit = LogOperationUnit.SYS_BANK_OPREATOR, operationType = LogOperationType.UPDATE)
    public CommonResult enable(String id, int state) {
        return sysBankOperatorService.enable(id, state);
    }

    /**
     * 修改银行用户
     *
     * @param sysBankOperator 银行用户
     * @return 结果
     */
    @RequestMapping("/update")
    @LogRecord(description = "修改银行用户", operationUnit = LogOperationUnit.SYS_BANK_OPREATOR, operationType = LogOperationType.UPDATE)
    public CommonResult update(SysBankOperator sysBankOperator) {
        return sysBankOperatorService.update(sysBankOperator);
    }

    /**
     * 查询银行用户详情
     *
     * @param id 用户ID
     * @return 用户详情
     */
    @RequestMapping("/getInfo")
    @LogRecord(description = "查询银行用户详情", operationUnit = LogOperationUnit.SYS_BANK_OPREATOR, operationType = LogOperationType.SELECT)
    public SysBankOperator getInfo(String id) {
        return sysBankOperatorService.getInfo(id);
    }

    /**
     * 精确查询/模糊查询 根据银行ID查询银行用户列表
     *
     * @param page            分页
     * @param sysBankOperator 查询实体
     * @param fuzzy           模糊查询字段
     * @return 用户列表
     */
    @RequestMapping("/getList")
    @LogRecord(description = "根据银行ID查询银行用户列表", operationUnit = LogOperationUnit.SYS_BANK_OPREATOR, operationType = LogOperationType.SELECT)
    public PageInfo<SysBankOperator> getList(Page page, SysBankOperator sysBankOperator, String fuzzy) {
        return sysBankOperatorService.getList(page, sysBankOperator, fuzzy);
    }

    /**
     * 精确查询/模糊查询 查询承办银行列表
     *
     * @param page                   分页实体
     * @param baseContractorBankInfo 查询实体
     * @param fuzzy                  模糊查询字段
     * @return 承办银行列表
     */
    @RequestMapping("/getContractorBankList")
    @LogRecord(description = "查询承办银行列表", operationUnit = LogOperationUnit.SYS_BANK_OPREATOR, operationType = LogOperationType.SELECT)
    public PageInfo<BaseContractorBankInfo> getContractorBankList(Page page, BaseContractorBankInfo baseContractorBankInfo, String fuzzy) {
        return sysBankOperatorService.getContractorBankList(page, baseContractorBankInfo, fuzzy);
    }
}
